package com.education.teacher.PubSub;

import com.education.util.EmailMsgModel;
import com.education.util.SendMailUtil;
import com.education.util.SerialUtil;
import org.apache.commons.codec.binary.Base64;
import redis.clients.jedis.JedisPubSub;

/**
 * Created by lzh on 2017/8/20.
 * redis消息队列 邮件订阅者
 */
public class EmailSuber extends JedisPubSub{

    /**
     * 处理消息
     * @param channel
     * @param message
     */
    @Override
    public void onMessage(String channel, String message) {
        byte[] bytes=Base64.decodeBase64(message);
        EmailMsgModel msgModel= SerialUtil.bytes2Object(bytes);

        SendMailUtil.send(msgModel);
    }
}
